<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>商家支付</title>
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
    <meta http-equiv="Pragma" content="no-cache"/>
    <meta http-equiv="Expires" content="0"/>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <script src="../js/jquery-3.3.1.min.js"></script>
    <style>
        .bindBox {
            width: 100%;
            text-align: center;
        }

        .bindBox img {
            margin: 1rem;
        }

        .bindCon {
            width: 100%;
            display: flex;
            justify-content: space-around;
        }

        .bindInput {
            height: 5rem;
            line-height: 5rem;
            width: 90%;
            border: 2px solid #c38e55;
            border-radius: 0.5rem;
            font-size: 1.5rem;
            color: #616161;
            padding: 0 3rem 0 1rem;
            box-sizing: border-box;
        }

        .bindBut {
            display: inline-block;
            width: 90%;
            height: 5rem;
            text-align: center;
            line-height: 5rem;
            background: #fe7c1f;
            color: #ffffff;
            border: none;
            margin-top: 1rem;
            border-radius: 5px;
            font-size: 1.5rem;
            cursor: pointer;
        }
    </style>

</head>
<body>
<div class="bindBox">
    <form>
        <img src="../image/shangjia.png"/>
        <div class="bindCon">

            <input hidden name="id" th:value="${mchPayCode.id}">
            <input hidden name="code" th:value="${mchPayCode.code}">
            <input type="text" name="deviceId" class="bindInput" placeholder="请输入设备编号">

        </div>
        <span class="bindBut">保存</span>
    </form>
</div>
<script>

    $('.bindBut').click(function () {
        console.log(1)
        var formData = $('form').serializeArray(),
            tempObj = {};
        $.each(formData, function (i, obj) {
            tempObj[obj.name] = obj.value;
        });

        $.ajax({
            type: 'post',
            url: '../code/register',
            data: {
                'id': tempObj.id,
                'code': tempObj.code,
                'deviceId': tempObj.deviceId
            },
            success: function (resp) {
                if (resp.code == 1) {
                    alert("绑定成功");
                    window.location.reload();
                } else {
                    alert(resp.message);
                }
            }
        });
    });
</script>
</body>
</html>